home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1996 #6
/
Amiga Plus CD - 1996 - No. 06.iso
/
pd
/
netz
/
internet-set.v4.0
/
amitcp-4.0
/
bin
/
netdial.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1996-07-24
|
12KB
|
378 lines
/* dialnet.rexx */
/* */
/* Version 1.0, 11 December 1993, by P.J. Rovero */
/* 1.2, 19 December 1993 */
/* 1.3, 30 December 1993, by K. Raquel Sanborn (raquels@uhunix) */
/* 1.4, 3 January 1994, Fix reboot Amiga without lose of CSLIP */
/* 1.5, 5 January 1994, Fix mounting of APIPE: */
/* 1.6, 6 January 1994, Add BREAK C support and "PROTECT +S" */
/* 1.7, 6 January 1994, Add FAILTAT 21 for mount >NIL: APIPE: */
/* 2.0, 20 December 1994, Redesign by Wes Tatters */
/* for AmiTCP 4.0 */
/* Now uses parameter passing instead of */
/* script building. */
/* Calls dialnet.connect to launch AmiTCP */
/* 2.1, 1 March 1995, Configured for AUSNET @ world.net */
/* This service needs Login: before Slip: */
/* */
/* */
/* 2.23, 20 Jan 1996, Adjusted by Kevin Anderson and configured */
/* for Bogomip ISP andersok@mail.bogo.co.uk */
/* 3.10, 18 July 1996 Fully auto using .dat file for username etc */
/* no editing required uses prefs files to get */
/* user and ISP details and save in user.dat, */
/* ISP.dat and Modem.dat plus reconnect added. */
/* */
/* An ARexx script that will dial a terminal server, connect, determine */
/* the dynamically assigned IP address, and start the proper components */
/* of AmiTCP 4.x. The script uses rexxserdev.library v5.x by Joseph M. */
/* Stivaletta. */
/* */
/* Inspired by Dave Bolen's REXX/2 SLIPUP.CMD for IBM OS/2 TCPIP 1.2.1 */
/* */
/* and AmiTCP_dialup10 by K. Raquel Sanborn */
/* */
/* ---------------------------------------------------------------------- */
/* Define general strings and other initialization stuff */
say 'Setting Control Variables...'
cr = '0d'x
crlf = '0d0a'x
lf = '0a'x
say 'Setting User Variables...'
dtimeout = 30 /* Dial time out in Seconds */
ctimeout = 15 /* Connect time out in Secs */
/* Read user.dat file and get variables */
If Open(1,'AmiTCP:bin/user.dat','Read') Then /* open file for Input */
BogoBit$ = ReadLn(1) /* read file 1 into Bogobit$ variable */
parse var BogoBit$ BogoName'*'BogoWord'*'BogoSpeed /* split out variables */
/* Read Modem.dat file for AT code string */
Close(1)
If Open(2,'AmiTCP:bin/Modem.dat','Read') Then
ModemSet = ReadLn(2) /* Read Modem AT code string from file 2 */
Close(2)
/* Read ISP.dat for Service Provider details */
If Open(3,'AmiTCP:bin/ISP.dat','Read') Then
ISPdet = ReadLn(3) /* Read ISP details from file 3 */
parse var ISPdet host_name'*'host_ip'*'ISPnum'*'Ispslip'*'AskPass
Close(3)
/************************* IMPORTANT *****************************/
/* */
/* PLEASE DO NOT EDIT THIS SCRIPT UNLESS YOU FEEL BRAVE AND KNOW */
/* WHAT YOUR DOING all editing is taken care of by the .prefs icons. */
/* */
/************************ USER INFORMATION *****************************/
/* */
username = BogoName||cr
passwd = BogoWord||cr
/* */
/********************* ISP's Information ****************************/
dialstr = 'ATDT'||ISPnum||cr
logprompt = 'name:'
passprompt = 'word:'
slipprompt = '*'
slip_cmd = ISPslip||cr
iptype = 'cslip0' /* slip0 for SLIP sites */
/* cslip0 for CSLIP sites */
/****************************************************************************/
say 'Setting Modem Variables...'
at_cmd = 'ATz'||cr
response = 'OK'
modemescape = '+++'
modeminit = ModemSet||cr
connectstr = 'CONNECT'
busystr = 'BUSY'
nocarrierstr = 'NO CARRIER'
nodialtonestr = 'NO DIALTONE'
/**************************************************************************/
/* Start the required libraries */
say 'Opening libraries...'
say ''
check = addlib('rexxsupport.library', 0, -30, 0)
if (check == 0) then say 'rexxsupport library already open...'
check = addlib('rexxserdev.library', 0, -30, 0)
if (check == 0) then say 'rexxserdev library already open...'
/* Open the serial device and talk to the modem */
say 'Setting up your serial device...'
say ''
serhandle = SerOpen('serial.device', 0)
check = SerClear(serhandle)
check = SerSetParms( serhandle, BogoSpeed, 8, N, 1, 0 )
/* Clean up on "BREAK C" */
buffer = allocmem( 4096 )
junk = c2d( buffer )
signal on break_c
/* Initialize Modem */
say 'Initializing Modem and sending it your AT code string'
say ''
result = SerWrite( serhandle, '+++', length( '+++' ) )
check = delay(200)
result = SerWrite( serhandle, modeminit, length( modeminit ) )
say 'Waiting for '||response||' ** If it stops here refer to Modem.help'
say ''
call wait_str( response )
/* Dial & wait for a connection and the modem status string */
dtime = 0
say 'Dialing your ISP... '
say ''
check = 0
do forever
if (check == 0) then
do
result = SerWrite( serhandle, dialstr, length( dialstr))
check = 1
totalstr = ''
end
status = SerQuery( serhandle )
parse upper var status valid bytes_read status_bits .
rcvdstr = SerRead( serhandle, junk, bytes_read )
totalstr = totalstr||rcvdstr
dtime = dtime + 1
if ( dtime >= dtimeout ) then
do
say Dialer timed out !!!
result = break_c()
end
say "Dialing: "||totalstr
test = pos(connectstr, totalstr)
if (test ~= 0) then leave
test = pos(busystr, totalstr)
if (test ~= 0) then
do
result = delay( 500 )
check = 0
end
test = pos(nocarrierstr, totalstr)
if (test ~= 0) then exit 20
test = pos(nodialtonestr, totalstr)
if (test ~= 0) then exit 20
result = delay(100)
end
totalstr = ''
say ''
say 'Modem has connected to your ISP...'
check = delay(50)
check = SerFlush( serhandle, 'R')
check = delay(50)
/* send CR to wake up terminal server */
say 'Sent CR to wake up your ISP...'
check = SerWrite( serhandle, cr, length( cr ))
say ''
say 'Waiting for CSLIP Server... '
check = 0
online = 0
totalstr = ''
ctime = 0
do forever
status = SerQuery( serhandle )
parse upper var status valid bytes_read status_bits .
rcvdstr = SerRead( serhandle, junk, bytes_read )
totalstr = totalstr||rcvdstr
say totalstr
ctime = ctime + 1
if ( ctime >= ctimeout ) then
do
say Dialer could not negotiate connection !!!
result = break_c()
end
test = pos( 'No response', totalstr )
if ( test ~= 0 ) then
do
say 'Connection failed ...'
result = break_c()
end
test = pos( logprompt, totalstr )
if ( test ~= 0 ) then
do
ctime = 0
totalstr = ''
online = online + 1
say 'Received username prompt...'
check = SerWrite( serhandle, username, length( username ))
check = SerRead( serhandle, junk, length(username))
say 'Sent your username...'
say ''
end
test = pos( passprompt, totalstr )
if ( test ~= 0 ) then
do
ctime = 0
totalstr = ''
online = online + 2
say 'Received password prompt...'
check = SerWrite( serhandle, passwd, length( passwd ))
say 'Sent your password...'
end
test = pos( slipprompt, totalstr )
if ( test ~= 0 ) then
do
ctime = 0
totalstr = ''
online = online + 3
say 'Received Slip command prompt sending Slip Command ...'
say ''
check = SerWrite( serhandle, slip_cmd, length( slip_cmd ) )
check = SerRead( serhandle, junk, length( slip_cmd ) )
end
if (online == AskPass) then leave /* checks total of online variable */
result = delay(100)
end
totalstr = ''
say 'Connected to your ISP, just waiting for IP addresses...'
address command
'wait 2 secs'
call wait_str('address')
say 'IP address received from Host system...'
say ''
/* Ok, now we have all the data we need to start Cslip */
/* Close down the serial port but leave the line up (ignore DTR) */
check = SerClose( serhandle )
result = startslip()
check = freemem(buffer,4096)
exit result
/* ------------------------------------------------------------- */
/* Exit point for "Break C" or ^C */
/* ------------------------------------------------------------- */
break_c:
say 'Cleaning up before exit...'
say 'Initializing Modem'
result = SerWrite( serhandle, '+++', length( '+++' ) )
check = delay(200)
result = SerWrite( serhandle, modeminit, length( modeminit ) )
check = SerClose( serhandle )
say 'Serial Port closed Now Click The Close Gadget'
check = freemem(buffer,4096)
exit
/* ------------------------------------------------------------- */
/* procedure startslip */
/* */
/* Start and configure AmiTCP for SLIP */
/* ------------------------------------------------------------- */
startslip:
parse var rcvdstr . 'IP address is ' a '.' b '.' c '.' d '.'.
slip_ip = a||'.'||b||'.'||c||'.'||d
/* Write reconnect ENV variable in case of crash */
Recon$ = slip_ip BogoSpeed
If Open(2,'ENVARC:reconnect','Write') Then
Do
WriteLn(2,Recon$) Then
End
Say 'Ignore these silly error messages there just result codes'
Close(2)
Say 'Yes these ones'
say 'AmiTCP:bin/netdial.connect starting'
say ''
say 'nearly there Now for the big message thingy'
say ''
'AmiTCP:bin/netdial.connect '||host_name||' '||host_ip||' '||slip_ip||' '||amiganame||' '||iptype||' '||BogoSpeed
return 0
/* ------------------------------------------------------------- */
/* Subroutine wait_str returns when argument string is received */
/* ------------------------------------------------------------- */
wait_str:
teststr = arg(1)
check = 0
do until (check ~= 0)
status = SerQuery( serhandle )
parse upper var status valid bytes_read status_bits .
rcvdstr = SerRead( serhandle, junk, bytes_read )
check = pos(teststr,rcvdstr)
test = delay(50)
end
return